import request from '@/utils/request'

// 获取课程列表
export const getCourseList = (params) => {
  return request({
    url: '/v2/course',
    method: 'GET',
    params
  })
}

// 获取用户已选择课程
export const getCourseListByUserSelected = (params) => {
  return request({
    url: '/v2/course/selected',
    method: 'GET',
    params
  })
}

// 获取指定用户未选择的课程
export const getCourseListNoSelected = (params) => {
  return request({
    url: '/v2/course/no',
    method: 'GET',
    params
  })
}

// 创建or修改课程
export const createOrUpdateCourse = (data) => {
  return request({
    url: '/v2/course',
    method: 'POST',
    data
  })
}

// 获取课程详情
export const getCourseDetails = (id) => {
  return request({
    url: `/v2/course/${id}`,
    method: 'GET'
  })
}

// 删除课程
export const deleteCourse = (params) => {
  return request({
    url: `/v2/course`,
    method: 'DELETE',
    params
  })
}

// 给用户添加课程
export const addCourseToUser = (data) => {
  return request({
    url: '/v2/course/user/add',
    method: 'POST',
    data
  })
}

// 给用户取消课程
export const deleteCourseToUser = (data) => {
  return request({
    url: '/v2/course/user/cancellation',
    method: 'POST',
    data
  })
}

// 获取某一课程附件列表
export const getCourseProfile = (params) => {
  return request({
    url: '/v2/course/annex/list',
    method: 'GET',
    params
  })
}

// 给课程添加附件
export const addFileToCourse = (data) => {
  return request({
    url: '/v2/course/annex/add',
    method: 'POST',
    data
  })
}

// 删除课程的附件
export const deleteFileToCourse = (data) => {
  return request({
    url: '/v2/course/annex',
    method: 'DELETE',
    data
  })
}

// 添加章节测试
export const createCourseTest = (data) => {
  return request({
    url: '/v2/course/test',
    method: 'POST',
    data
  })
}

// 修改章节测试
export const editCourseTest = (params) => {
  return request({
    url: '/v2/course/test',
    method: 'PUT',
    params
  })
}

// 获取课程单元测试列表
export const getCourseTestList = (params) => {
  return request({
    url: '/v2/course/test/admin/list',
    method: 'GET',
    params
  })
}

// 获取测试详情
export const getCourseTestDetails = (unitTestId) => {
  return request({
    url: `/v2/course/test/${unitTestId}`,
    method: 'GET'
  })
}

// 删除课程测试卷
export const deleteCourseTest = (params) => {
  return request({
    url: '/v2/course/test',
    method: 'DELETE',
    params
  })
}
